package com.rambo.sdh.service.impl;

import com.rambo.sdh.dao.inter.UserDao;
import com.rambo.sdh.dao.pojo.RolePO;
import com.rambo.sdh.dao.pojo.UserPO;
import com.rambo.sdh.service.inter.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import javax.annotation.Resource;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	
	@Autowired
    private UserDao userDao;

    
    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserPO findUserByUuid(Integer id) {
        return userDao.getByKey(id);
    }

    public UserPO addUser(UserPO user) {
        return userDao.add(user);
    }

    public UserPO updateUser(UserPO user) {
        return userDao.edit(user);
    }

    public int deleteUserById(Integer uuid) {
        return userDao.deleteByKey(uuid);
    }

    public List<UserPO> getUserList() {
        return userDao.getUserList();
    }

	@Override
	public List<RolePO> getRolePOByUserId(Integer id) {
		
		return userDao.getRolePOByUserId(id);
	}

	@Override
	public List<UserPO> getUserPOByRoleId(Integer id) {
		
		return userDao.getUserPOByRoleId(id);
	}
}
